﻿@{
    ViewBag.Title = "FirstTrialDetails";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}

<script>
    var keyValue = request('keyValue');
    var chcekmemo = decodeURI(request('chcekmemo'));
    var Id = "", State = "";
    var RoomList1 = [], RoomList2 = [], RoomList3 = [], File = [];
    $(function () {
        InitialPage();
        InitControl();
    });
    //初始化数据
    function InitControl() {
        if (!!keyValue) {
            $.SetForm({
                url: "../../QualificationManage/FirstTrial/GetBillInfo",
                param: { keyValue: keyValue },
                success: function (data) {
                    Id = data.BillInfo.Id;
                    State = data.BillInfo.State;
                    $("#FileSubmitCount").text(data.BillInfo.FileSubmitCount == 0 ? 1 : data.BillInfo.FileSubmitCount);
                    $("#State").text(GetState(data.BillInfo.State));
                    $("#QualificationBill").SetWebControls(data.BillInfo);
                    $("#SQRXX").SetWebControls(data.MemberInfo);
                    $("#Address").val(data.BillInfo.Address);
                    GetGrid1(data.ResidentList);
                    GetRommListByCategory(data.RoomList)
                    GetGrid2(RoomList2);
                    GetGrid3(RoomList3);
                    GetGrid4(RoomList1);
                    GetGrid5(data.CheckRecordList);
                    TranslateInfoState();
                    GetAccessory(data.FileList);
                    if (State >= 4) {
                        $("#Submit").attr("disabled", "disabled");
                        $("#chk").attr("checked", "checked");
                        $("#chk").attr("disabled", "disabled");
                        $("#Uchk").attr("disabled", "disabled");
                    }
                    if (State == 3) {
                        $("#Memo").val(chcekmemo);
                        $("#Uchk").attr("checked", "checked");
                        $("#Try").removeAttr("hidden");
                        $("#Memo").attr("disabled", "disabled");
                        $("#chk").attr("disabled", "disabled");
                        $("#Uchk").attr("disabled", "disabled");
                        $("#Submit").attr("disabled", "disabled");

                    }
                }
            })
        }


    }
    //初始化页面
    function InitialPage() {
        //layout布局
        $('#layout').layout({
            applyDemoStyles: true,
            onresize: function () {
                $(window).resize()
            }
        });
        $('.profile-content').height($(window).height() - 20);
        $('.profile-nav').height($(window).height() - 20);
    }
    //侧面切换显示/隐藏
    function profileSwitch(id) {
        if (id == "BillContent") {
            $("#TrialRecord").hide();
            $("#BillContent").show();
        }
        else {
            $("#BillContent").hide();
            $("#TrialRecord").show();

        }
    };
    //共同申请人信息
    function GetGrid1(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable1");
        $gridTable.jqGrid({
            datatype: "json",
            height: 150,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "姓名", name: "Name", index: "Name", width: 200, align: "center", sortable: false },
                { label: "性别", name: "Sex", index: "Sex", width: 200, align: "center", sortable: false },
                { label: "身份证号码", name: "IDCard", index: "IDCard", width: 200, align: "center", sortable: false },
                { label: "与申请人关系", name: "Relation", index: "Relation", width: 200, align: "center", sortable: false },
                { label: "本市常住人口", name: "IsPermanent", index: "IsPermanent", width: 200, align: "center", sortable: false },
                { label: "婚姻状况", name: "MarryInfo", index: "MarryInfo", width: 200, align: "center", sortable: false }
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            },
        });
        $gridTable[0].addJSONData(data);

    };
    //申请人本市户籍地住房情况
    function GetGrid2(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable2");
        $gridTable.jqGrid({
            datatype: "json",
            height: 150,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "房屋坐落地址", name: "Address", index: "Address", width: 200, align: "center", sortable: false },
                { label: "建筑面积", name: "Area", index: "Area", width: 200, align: "center", sortable: false },
                { label: "使用面积", name: "UseArea", index: "UseArea", width: 200, align: "center", sortable: false },
                { label: "产权人或公房承租人", name: "Owner", index: "Owner", width: 200, align: "center", sortable: false },
                { label: "该住房户籍人口总数", name: "PeopleCount", index: "PeopleCount", width: 200, align: "center", sortable: false },
                {
                    label: "产权类型", name: "Category", index: "Category", width: 200, align: "center", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var Msg = "";
                        switch (cellvalue) {
                            case 1: Msg = "公有住房";
                                break;
                            case 2: Msg = "本市户籍地住房";
                                break;
                            case 3: Msg = "本市产权房";
                                break;
                            default: Msg = "---";
                                break;
                        }
                        return Msg;
                    }
                },
                { label: "房屋类型", name: "RoomType", index: "RoomType", width: 200, align: "center", sortable: false },

            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable[0].addJSONData(data);

    };
    //申请人拥有本市产权住房情况
    function GetGrid3(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable3");
        $gridTable.jqGrid({
            datatype: "json",
            height: 150,
            autowidth: true,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "房屋坐落地址", name: "Address", index: "Address", width: 200, align: "center", sortable: false },
                { label: "建筑面积", name: "Area", index: "Area", width: 200, align: "center", sortable: false },
                { label: "产权人", name: "Owner", index: "Owner", width: 200, align: "center", sortable: false },
                { label: "该住房户籍人口总数", name: "PeopleCount", index: "PeopleCount", width: 200, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable[0].addJSONData(data);

    };
    //申请人承租本市共有住房情况
    function GetGrid4(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable4");
        $gridTable.jqGrid({
            datatype: "json",
            height: 150,
            autowidth: true,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "房屋坐落地址", name: "Address", index: "Address", width: 200, align: "center", sortable: false },
                { label: "建筑面积", name: "Area", index: "Area", width: 200, align: "center", sortable: false },
                { label: "使用面积", name: "UseArea", index: "UseArea", width: 200, align: "center", sortable: false },
                { label: "产权人或公房承租人", name: "Owner", index: "Owner", width: 200, align: "center", sortable: false },
                { label: "该住房户籍人口总数", name: "PeopleCount", index: "PeopleCount", width: 200, align: "center", sortable: false },
                {
                    label: "产权性质", name: "Category", index: "Category", width: 200, align: "center", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var Msg = "";
                        switch (cellvalue) {
                            case 1: Msg = "公有住房";
                                break;
                            case 2: Msg = "本市户籍地住房";
                                break;
                            case 3: Msg = "本市产权房";
                                break;
                            default: Msg = "---";
                                break;
                        }
                        return Msg;
                    }
                },
                { label: "房屋类型", name: "RoomType", index: "RoomType", width: 200, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable[0].addJSONData(data);

    };
    //审核记录
    function GetGrid5(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable5");
        $gridTable.jqGrid({
            datatype: "json",
            height: $(window).height() - 141,
            autowidth: true,
            colModel: [
                { label: "主键", name: "Id", hidden: true },
                { label: "提交时间", name: "Date", index: "Date", width: 200, align: "center", sortable: false },
                { label: "审核人", name: "CheckMan", index: "CheckMan", width: 200, align: "center", sortable: false },
                { label: "审核时间", name: "CheckDate", index: "CheckDate", width: 200, align: "center", sortable: false },
                {
                    label: "审核结果", name: "CheckFlag", index: "CheckFlag", width: 300, align: "center", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        var Msg = "<span  class='label' style='background-color:";
                        //;
                        if (rowObject.Type == 1) {
                            if (cellvalue == 0) {
                                Msg += "#B05B5C'>" + "初审未通过"
                            }
                            else {
                                Msg += "#BCD186'>" + "初审通过"
                            }
                        }
                        if (rowObject.Type == 2) {
                            if (cellvalue == 0) {
                                Msg += "#839B27'>" + "材料未通过"
                            }
                            else {
                                Msg += "#81B981'>" + "材料通过"
                            }
                        }
                        if (rowObject.Type == 3) {
                            if (cellvalue == 0) {
                                Msg += "#F09005'>" + "市局审批未通过"
                            }
                            else {
                                Msg += "#5CB85C'>" + "市局审批通过"
                            }
                        }
                        if (rowObject.Type == 4) {
                            if (cellvalue == 0) {
                                Msg += "#f00'>" + "复审未通过"
                            }
                            else {
                                Msg += "#5CB85C'>" + "复审通过"
                            }
                        }
                        Msg += "</span>";
                        return Msg;
                    }

                },
                { label: "不通过原因", name: "CheckMemo", index: "CheckMemo", width: 650, align: "center", sortable: false },
            ],
            viewrecords: true,
            // rowNum: "all",
            rowNum: 30,
            rowList: [30, 50, 100],
            pager: "#gridPager5",
            sortname: 'Date',
            sortorder: 'desc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable[0].addJSONData(data);

    };
    //转换审批状态
    function GetState(value) {
        var Msg = "";
        switch (value) {
            case 1: Msg = "初审中（初次)";
                break;
            case 2: Msg = "初审中（再次）";
                break;
            case 3: Msg = "初审未通过";
                break;
            case 4: Msg = "递交资料中（初审通过）";
                break;
            case 5: Msg = "市局审批中（材料通过）";
                break;
            case 6: Msg = "复审（市局审批通过）";
                break;
            case 7: Msg = "复审通过";
                break;
            case 8: Msg = "复审未通过";
                break;
            case 9: Msg = "客户撤回";
                break;
            default: Msg = "---";
                break;
        }
        return Msg;
    };
    //分类房屋情况
    function GetRommListByCategory(list) {

        var Data = [];
        Data = list;
        for (var i = 0; i < Data.length; i++) {
            if (Data[i].Category == 1) {
                RoomList1.push(Data[i]);
            }
            if (Data[i].Category == 2) {
                RoomList2.push(Data[i]);
            }
            if (Data[i].Category == 3) {
                RoomList3.push(Data[i]);
            }
        }
    };
    //装换信息状态
    function TranslateInfoState() {
        if ($("#Sex").val() == 1) {
            $("#Sex").val("男");
        }
        if ($("#Sex").val() == 2) {
            $("#Sex").val("女");
        }
        $(".IsState").each(function () {
            if ($(this).val() == 1) {
                $(this).val("是");
            }
            if ($(this).val() == 0) {
                $(this).val("否");
            }
        })

    };
    //获取附件信息
    function GetAccessory(data) {
        File = data;
        var html1 = "";
        var html2 = "";
        
        for (var i = 0; i < File.length; i++) {
            switch (File[i].FileType) {
                case 1: //图片
                    html1 += "<td><div class='CS_C'ondblclick='GetAccess(\"" + File[i].FileUrl + "\");'><div class=CS_T><img src='" + File[i].FileUrl + "'alt='加载失败' /></div><div class='CS_D'>" + File[i].FileName + "</div></div></td>"
                    break;
                default: break;

            }
        }
        $("#CS_IO").html(html1);
    }
    //查看及下载附件
    function GetAccess(Url) {
        var a;
        a = window.open(Url, "_blank", "width=0, height=0,status=0");

    };


</script>

<style>
    #SQRXX {
        border: 1px solid #ccc;
    }

        #SQRXX td {
            border: 1px solid #ccc;
        }

    #CS_IO td {
        margin: 10px;
        width: 180px;
        height: 110px;
    }

    .CS_C {
        margin: 10px;
        width: 160px;
        height: 110px;
        border: solid 1px #F0F0F0;
        margin: 10px;
    }

        .CS_C:hover {
            border: solid 1px #AFD4FA;
            background-color: #F5FAFF;
        }

    .CS_T {
        width: 160px;
        height: 70px;
        line-height: 70px;
        text-align: center;
    }

        .CS_T img {
            width: 50px;
        }

    .CS_D {
        width: 160px;
        height: 40px;
        text-align: center;
    }

    .Cs_1 {
        background-color: #DDF0ED;
        width: 150px;
        text-align: center;
        font-size: 14px;
        height: 30px;
    }

    .Cs_2 {
        text-align: center;
    }

    .form-control {
        border: none;
    }
</style>
<div class="ui-layout" id="layout" style="height: 100%;  width: 100%;">
    <div class="ui-layout-west">
        <div class="west-Panel">
            <div class="profile-nav">
                <ul style="padding-top: 20px;">
                    <li class="active" onclick="profileSwitch('BillContent')">单据内容</li>
                    <li onclick="profileSwitch('TrialRecord')">审核记录</li>
                </ul>
            </div>
        </div>
    </div>
    <div class="ui-layout-center">
        <div class="center-Panel">
            <div class="profile-content" style="background: #fff; ">
                <div id="BillContent">
                    <table class="form" id="QualificationBill" style="margin-top: 20px;">
                        <tr>
                            <td class="formTitle">单据编号：</td>
                            <td class="formValue"><input class="form-control" readonly id="Code" type="text" /></td>
                            <td class="formTitle">创建时间：</td>
                            <td class="formValue"><input class="form-control" readonly id="CreateDate" type="text" /></td>
                            <td class="formTitle">提交时间：</td>
                            <td class="formValue"><input class="form-control" readonly id="Date" type="text" /></td>
                            <td>第<span id="FileSubmitCount" style="color:red;font-size:24px;"></span>次提交</td>
                        </tr>
                        <tr>
                            <td class="formTitle">初审状态：</td>
                            <td class="formValue" colspan="4">
                                <span style="color:red;font-size:24px;" id="State"></span>
                            </td>
                            <td></td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="7"></td> </tr>
                        <tr style="height:10px;"></tr>
                        <tr><td colspan="7"><h4>申请人信息</h4></td></tr>
                    </table>
                    <table class="form" id="SQRXX" style="margin-top: 20px;">
                        <tr>
                            <td class=" Cs_1">姓名</td>
                            <td class="formValue"><input class="form-control" readonly id="Name" type="text" /></td>
                            <td class=" Cs_1">身份证号</td>
                            <td class="formValue"><input class="form-control" readonly id="IDCard" type="text" /></td>
                            <td class=" Cs_1">性别</td>
                            <td class="formValue"><input class="form-control" readonly id="Sex" type="text" /></td>
                            <td class=" Cs_1">民族</td>
                            <td class="formValue"><input class="form-control" readonly id="Nation" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">文化程度</td>
                            <td class="formValue"><input class="form-control" readonly id="Cultural" type="text" /></td>
                            <td class=" Cs_1">手机号码</td>
                            <td class="formValue"><input class="form-control" readonly id="Phone" type="text" /></td>
                            <td class=" Cs_1">固定电话</td>
                            <td class="formValue"><input class="form-control" readonly id="PhoneNum" type="text" /></td>
                            <td class=" Cs_1">婚姻状况</td>
                            <td class="formValue"><input class="form-control" readonly id="MarryInfo" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">户籍所在地</td>
                            <td class="formValue" colspan="7"><input class="form-control" readonly id="HouseholdAddress" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">通讯地址</td>
                            <td class="formValue" colspan="5"><input class="form-control" readonly id="Address" type="text" /></td>
                            <td class=" Cs_1">邮编</td>
                            <td class="formValue"><input class="form-control" readonly id="HouseholdPostalCode" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">是否办理本市居住证</td>
                            <td class="formValue"><input class="form-control IsState" readonly id="HasLiveCard" type="text" /></td>
                            <td class=" Cs_1">居住证号码</td>
                            <td class="formValue"><input class="form-control" readonly id="LiveCard" type="text" /></td>
                            <td class=" Cs_1">持证是否满两年</td>
                            <td class="formValue"><input class="form-control IsState" readonly id="LiveCardFull2Year" type="text" /></td>
                            <td class=" Cs_1">是否缴纳社保金</td>
                            <td class="formValue"><input class="form-control IsState" readonly id="HasSocialSecurityFund" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">连续缴金是否满一年</td>
                            <td class="formValue"><input class="form-control IsState" readonly id="SocialSecurityFullYear" type="text" /></td>
                            <td class=" Cs_1">是否缴纳本市公积金</td>
                            <td class="formValue"><input class="form-control IsState" readonly id="HasProvidentFund" type="text" /></td>
                            <td class=" Cs_1">公积金账号</td>
                            <td class="formValue" colspan="3"><input class="form-control" readonly id="ProvidentFundCard" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">单位名称</td>
                            <td class="formValue" colspan="3"><input class="form-control" readonly id="CompanyName" type="text" /></td>
                            <td class=" Cs_1">单位电话</td>
                            <td class="formValue"><input class="form-control" readonly id="CompanyPhone" type="text" /></td>
                            <td class=" Cs_1">单位类别</td>
                            <td class="formValue"><input class="form-control" readonly id="CompanyType" type="text" /></td>
                        </tr>
                        <tr>
                            <td class=" Cs_1">单位地址</td>
                            <td class="formValue" colspan="5"><input class="form-control" readonly id="CompanyAddress" type="text" /></td>
                            <td class=" Cs_1">邮编</td>
                            <td class="formValue"><input class="form-control" readonly id="CompanyPostalCode" type="text" /></td>
                        </tr>
                    </table>
                    <br />
                    <h5>共同申请人信息</h5><br />
                    <div class="center-Panel">
                        <div class="gridPanel">
                            <table id="gridTable1"></table>
                        </div>
                    </div>
                    <br /> <h5>申请人本市户籍地住房情况</h5>
                    <div class="center-Panel">
                        <div class="gridPanel">
                            <table id="gridTable2"></table>
                        </div>
                    </div>
                    <br /> <h5>申请人拥有本市产权住房情况</h5>
                    <div class="center-Panel">
                        <div class="gridPanel">
                            <table id="gridTable3"></table>
                        </div>
                    </div>
                    <br /> <h5>申请人承租本市共有住房情况</h5>
                    <div class="center-Panel">
                        <div class="gridPanel">
                            <table id="gridTable4"></table>
                        </div>
                    </div>
                    <br /><h5>附件</h5><br />
                    <table class="form">
                        <tr id="CS_IO" style="height:110px;"></tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="5"></td> </tr>
                        <tr style="height:10px;"></tr>

                    </table>
                    <table class="form" style="background-color: #FFCC99;">
                        <tr>
                            <td style="text-align:right;">审核人：</td>
                            <td class="formValue"><input style="background-color: #FFCC99;" class="form-control" id="FirstCheckMan" type="text" value="@ViewBag.Man" /></td>
                            <td style="text-align:right;">审核时间：</td>
                            <td class="formValue"><input id="Date" style="background-color: #FFCC99;" type="text" class="form-control  " value="@LeSoft.Util.Time.GetToday("yyyy-MM-dd HH:mm:ss")" /></td>
                            <td style="text-align:right;">审核结果：</td>

                            <td>
                                &nbsp;&nbsp;<input name="Trial" type="radio" id="chk" disabled  value="1" />通过
                                &nbsp;&nbsp;&nbsp;&nbsp;<input name="Trial" id="Uchk" disabled  type="radio" value="0" />不通过
                            </td>
                            <td colspan="5"></td>

                        </tr>
                        <tr id="Try" hidden>
                            <td class="formTitle" style="text-align:right;">不通过原因:</td>
                            <td class="formValue" colspan="10">
                                <textarea class="form-control" id="Memo" disabled style="height:50px;"></textarea>
                            </td>
                        </tr>
                    </table>
                    <div style="height:50px;"></div>
                </div>
                <div id="TrialRecord" style="display: none;">
                    <div class="title">
                        审核记录
                    </div>

                    <div class="gridPanel">
                        <table id="gridTable5"></table>
                        <div id="gridPager5"></div>

                    </div>
                </div>

            </div>
        </div>
    </div>
</div>